﻿using System.Drawing;
using System.Windows.Forms;
using System.Text;

namespace PackageEditor
{
    public partial class ExceptionBox : Form
    {
        public ExceptionBox(string Message)
        {
            InitializeComponent();
            this.txtMessage.Text = Message;
            int lines = this.txtMessage.Lines.Length;
            this.txtMessage.Size = new Size(this.txtMessage.Size.Width, lines * 12);
            this.Size = new Size(this.Size.Width, this.txtMessage.Size.Height + 60);
            this.CenterToScreen();
            this.Icon = Properties.Resources.Icon;
        }
        

        public static void Show(string message)
        {
            StringBuilder b = new StringBuilder();
            ExceptionBox box = new ExceptionBox(b.Append("An exception is caught. Version number: ").Append(Application.ProductVersion)
                .AppendLine().Append("Exception Detail: ").AppendLine().AppendLine(message).ToString());
            box.Show();
        }

    }
}
